<template>
  <base-layout
    :dialog-title="dialogTitle"
    :dialog-visible="dialogVisible"
    @dialog-close="dialogClose"
    :dialogWidth="dialogWidth"
  >
    <template #searchPanel>
      <el-row :gutter="20">
        <search-panel
          v-slot="{ form }"
          @search="search"
          :showAddButton="true"
          addTitle="短信发送"
          @insert="addCaringReminder"
          :addPer="'caring:save'"
          :selectPer="'caring:page'"
        >
          <el-form-item label="发送时间:">
            <el-date-picker
              v-model="form.sendStartTime"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetime"
            >
            </el-date-picker>
            至
            <el-date-picker
              v-model="form.sendEndTime"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetime"
            >
            </el-date-picker>
          </el-form-item>
        </search-panel>
      </el-row>
    </template>
    <template #contentPanel>
      <data-table
        :value="tableData"
        :has-action="true"
        :table-column-attributes="tableColumnAttributes"
        :isShowPage="false"
      >
        <template #action="{ row }">
          <i
            class="el-icon-delete"
            title="删除"
            style="color: red; cursor: pointer"
            v-permission="'caring:deleted'"
            @click="handleDataDelete(row)"
          ></i>
        </template>
      </data-table>
      <!--工具条-->
    </template>
  </base-layout>
</template>

<script>
import { caringPage, deleteCaring } from '@/api/after-sale/client/caring'
import baseMixin from '@/mixins/base'
import { parseTimeToYMDHMS, parseTime } from '@/utils'

export default {
  components: {},
  mixins: [
    baseMixin({
      idName: 'id',
      findData: caringPage,
      deleteData: deleteCaring,
      dataName: ['content', 'totalRecords'],
    }),
  ],
  data() {
    return {
      tableColumnAttributes: [
        { name: '所属门店', value: 'storeName', type: 'text' },
        { name: '发送内容', value: 'content', type: 'text' },
        { name: '发送时间', value: 'createTime', type: 'text' },
        { name: '发送客户数', value: 'clientNum', type: 'text' },
        { name: '成功发送数', value: 'successNum', type: 'text' },
        { name: '失败数', value: 'errorNum', type: 'text' },
      ],
    }
  },
  async created() {},
  methods: {
    search(form) {
      this.searchOptions = {
        ...form,
      }
      this.currentPage = 1
      this.setTableData()
    },
    //短信新增
    addCaringReminder() {
      this.$router.push({ path: '/client-manage/create-reminder' })
    },
  },
}
</script>

<style lang="scss" scoped>
.vLine {
  border-left: solid 3px black;
  height: 16px;
  vertical-align: bottom;
  display: inline-block;
}
</style>
